<template>

  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="指标分类" prop="quotaClassify">
        <el-select v-model="queryParams.quotaClassify" placeholder="指标分类" clearable>
          <el-option v-for="dict in dict.type.indicator_classify" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="指标内容" prop="quotaDescription">
        <el-input v-model="queryParams.quotaDescription" placeholder="请输入指标内容" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="指标状态" prop="useStatus">
        <el-select v-model="queryParams.useStatus" placeholder="指标状态" clearable>
          <el-option v-for="dict in dict.type.indicator_state" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="指标类型" prop="scoreType">
        <el-select v-model="queryParams.scoreType" placeholder="指标类型" clearable>
          <el-option v-for="dict in dict.type.indicator_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="指标类别" prop="quotaType">
        <el-select v-model="queryParams.quotaType" placeholder="指标类别" clearable>
          <el-option v-for="dict in dict.type.indicator_category" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" v-hasPermi="['synthesize:evaluation:add']" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" v-hasPermi="['synthesize:evaluation:edit']" size="mini" @click="handleUpdate">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" v-hasPermi="['synthesize:evaluation:del']" size="mini" @click="handleDelete">删除</el-button>
      </el-col>
      <el-button type="warning" plain icon="el-icon-download" v-hasPermi="['synthesize:evaluation:export']" size="mini" @click="handleExport">导出</el-button>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="序号" align="center" prop="noticeId" width="160" /> -->
      <el-table-column label="指标内容" align="center" prop="quotaDescription" :show-overflow-tooltip="true" />
      <el-table-column label="最大分值" align="center" prop="maxScore" :show-overflow-tooltip="true" />
      <el-table-column label="指标分类" align="center" prop="quotaClassify" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.indicator_classify" :value="scope.row.quotaClassify"></dict-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column label="指标类型" align="center" prop="scoreType" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.indicator_type" :value="scope.row.scoreType"></dict-tag>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="指标类别" align="center" prop="quotaType" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.indicator_category" :value="scope.row.quotaType"></dict-tag>
        </template>
      </el-table-column> -->
      <el-table-column label="指标状态" align="center" prop="useStatus" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.indicator_state" :value="scope.row.useStatus"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column label="创建者" align="center" prop="createBy" width="100" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" v-hasPermi="['synthesize:evaluation:edit']" @click="handleUpdate(scope.row)">修改</el-button>
          <el-button size="mini" type="text" v-hasPermi="['synthesize:evaluation:del']" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <AddDlg ref="addDlgRef" @updateList="getList"> </AddDlg>
  </div>
</template>
  
<script>
import {
  evaluateList,
  delEvaluate
} from "@/api/assessmentCenter/evaluationIndex";
import AddDlg from './modules/add.vue'
export default {
  name: "evaluationIndex",
  dicts: [
    "indicator_classify",
    // "indicator_category",
    "indicator_state",
    // "indicator_type"
    ],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        quotaClassify: '',
        quotaDescription: '',
        useStatus: '',
        // scoreType: ''
      },
      total: 0,
      showSearch: true,
      tableData: [],
      ids: []
    };
  },
  components: {
    AddDlg
  },
  created() {
    this.getList();
  },
  computed: {

  },
  methods: {
    // 导出
    handleExport() {
      this.download(
        "/evaluate/quota/export",
        {
          ...this.queryParams
        },
        `指标管理_${new Date().getFullYear()}-${new Date().getMonth() +
        1}-${new Date().getDate()}.xlsx`
      );
    },
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.noticeId)
    },
    /** 查询列表 */
    getList() {
      evaluateList(this.queryParams).then(response => {
        this.tableData = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.reset();
      this.handleQuery();
    },
    reset() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        quotaClassify: '',
        quotaDescription: '',
        useStatus: '',
        // scoreType: ''
      };
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$refs.addDlgRef.open()
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$refs.addDlgRef.open(row)
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      if (!row && !this.ids.length) {
        this.$modal.info("请选择要删除的数据");
        return
      }
      const quotaIds = row.quotaId || this.ids.join(',')
      this.$modal.confirm(row.quotaId ? '确认删除该数据吗？' : '确认删除选中的数据吗？').then(function () {
        return delEvaluate(quotaIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    }
  },
  filters: {

  }
};
</script>
<style lang="scss" scoped></style>